<div id="content_header">
  <h3>Student Discounts</h3>
</div>

<div class="row row-unstyled">
  <div class="col-md-12">
    <label>SEARCH</label>
  </div>
</div>

<div class="row">
  <div class="col-md-6 col-lg-4">
    <form class="form-vertical" ng-submit="loadSD()">
      <div class="input-group">
        <input class="form-control" type="text" name="keyword" placeholder="Type Name to search" ng-model="params.student_name">
        <span class="input-group-btn">
          <button class="btn btn-default" type="button">Go!</button>
        </span>
      </div>
    </form>
  </div>
  <div class="col-md-6 col-lg-4">
    <a ui-sref="^.new" class="btn btn-primary">Register a new Student Discounts</a>
  </div>
</div>

<br>

<div class="row">
  <div class="col-md-12">
    <label>RESULTS</label>
    <div class="search-message">
      Found <span class="primary-color"><b>{{ totalItems }}</b></span> records
    </div>
  </div>
</div>
<div class="row">
  <div class="col-md-12">
    <tabset>
      <tab heading="Used">
        <table class="table table-striped table-bordered" ng-show="totalItems > 0">
          <thead>
            <tr>
              <th>Student</th>
              <th>Amount</th>
              <th>Percentage</th>
              <th>Discount Type</th>
              <th>Validity</th>
              <th>Published In</th>
              <th>Invoice Number</th>
              <th>Action</th>
            </tr>
          </thead>
          <tbody>
            <!-- <tr dir-paginate="item in items | orderBy: 'Name' | itemsPerPage: pagesize" total-items="totalItems"> -->
            <tr ng-repeat="item in items" ng-show="item.Invoice.Id">
              <td>
                {{ item.Student.FullName }}
                <br>
                {{ item.Student.SID }}
              </td>
              <td>{{ item.Amount? (item.Amount | currency:'Rp. ') : '-' }}</td>
              <td>{{ item.Percentage ? item.Percentage+'%' : '-' }}</td>
              <td>{{ item.DiscountType.Name }}</td>
              <td>
                {{ item.ValidFrom  | date:'mediumDate' }} - {{ item.ValidUntil  | date:'mediumDate' }}
                <br>
                <span class="label label-success" ng-if="item.IsValid">Valid</span><span class="label label-warning" ng-if="!item.IsValid">expired</span>
              </td>
              <td>{{ ((discount.PublishedInTermNumber) && (discount.PublishedInTermNumber > 0)) ? (discount.PublishedInTermNumber + '/' + discount.PublishedInTermYear) : '-' }}</td>
              <td>{{ item.Invoice.InvoiceNumber }}</td>
              <td>
                <a class="" href ng-really-message="Are you sure want to delete this data?" ng-really-click="delete('student_discounts', item.Id, {collection: items, index: $index})"><i class="simple-icon-trash"></i></a>
                <a class="" ui-sref="^.show({id: item.Id})"><i class="glyphicon glyphicon-edit"></i></a>
              </td>
            </tr>
          </tbody>
        </table>
        <!-- <dir-pagination-controls on-page-change="pageChanged(newPageNumber)" template-url="views/templates/dirPagination.tpl.html"></dir-pagination-controls> -->
      </tab>
      <tab heading="Available">
        <table class="table table-striped table-bordered" ng-show="totalItems > 0">
          <thead>
            <tr>
              <th>Name</th>
              <th>Amount</th>
              <th>Percentage</th>
              <th>Discount Type</th>
              <th>Validity</th>
              <th>Published In</th>
              <th>Action</th>
            </tr>
          </thead>
          <tbody>
            <!-- <tr dir-paginate="item in items | orderBy: 'Name' | itemsPerPage: pagesize" total-items="totalItems"> -->
            <tr ng-repeat="item in items" ng-hide="item.Invoice.Id">
              <td>
                {{ item.Student.FullName }}
                <br>
                {{ item.Student.SID }}
              </td>
              <td>{{ item.Amount? (item.Amount | currency:'Rp. ') : '-' }}</td>
              <td>{{ item.Percentage ? item.Percentage+'%' : '-' }}</td>
              <td>{{ item.DiscountType.Name }}</td>
              <td>{{ item.ValidFrom  | date:'mediumDate' }} - {{ item.ValidUntil  | date:'mediumDate' }}</td>
              <td>{{ ((discount.PublishedInTermNumber) && (discount.PublishedInTermNumber > 0)) ? (discount.PublishedInTermNumber + '/' + discount.PublishedInTermYear) : '-' }}</td>
              <td>
                <a class="" href ng-really-message="Are you sure want to delete this data?" ng-really-click="delete('student_discounts', item.Id, {collection: items, index: $index})"><i class="simple-icon-trash"></i></a>
                <a class="" ui-sref="^.show({id: item.Id})"><i class="glyphicon glyphicon-edit"></i></a>
              </td>
            </tr>
          </tbody>
        </table>
        <!-- <dir-pagination-controls on-page-change="pageReceipt(newPageNumber)" pagination-id="receipt_pagination_id" template-url="views/templates/dirPagination.tpl.html"></dir-pagination-controls> -->
      </tab>
    </tabset>
  </div>
</div>